<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}会议管理系统{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <link rel="stylesheet" href="/static/css/style.css">
    {% block extracss %}{% endblock %}
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="/">
                <i class="bi bi-calendar-event me-2"></i>会议管理系统
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/dashboard">
                            <i class="bi bi-speedometer2 me-1"></i>仪表盘
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/meetings">
                            <i class="bi bi-calendar-week me-1"></i>会议列表
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/my-meetings">
                            <i class="bi bi-person-video me-1"></i>我的会议
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/rooms">
                            <i class="bi bi-building me-1"></i>会议室
                        </a>
                    </li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item dropdown" id="user-nav" style="display: none;">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
                            <i class="bi bi-person-circle me-1"></i><span id="username-display">用户</span>
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end">
                            <li><a class="dropdown-item" href="/profile"><i class="bi bi-person me-2"></i>个人资料</a></li>
                            <li><a class="dropdown-item" href="/settings"><i class="bi bi-gear me-2"></i>设置</a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="#" id="logout-btn"><i class="bi bi-box-arrow-right me-2"></i>退出登录</a></li>
                        </ul>
                    </li>
                    <li class="nav-item" id="login-nav">
                        <a class="nav-link" href="/login">
                            <i class="bi bi-box-arrow-in-right me-1"></i>登录
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        {% block content %}{% endblock %}
    </div>

    <footer class="text-center py-4 mt-5 bg-light">
        <div class="container">
            <p class="mb-0">© 2025 特软二班会议管理系统 - 基于FastAPI构建</p>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="/static/js/app.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            initAuth();
            initLogoutButton();
        });

        // 只在有表单的页面绑定事件
        const form = document.getElementById('createMeetingForm');
        if (form) {
            form.addEventListener('submit', function(e) {
                e.preventDefault();
                const data = {
                    title: document.getElementById('title').value,
                    start_time: document.getElementById('start_time').value,
                    end_time: document.getElementById('end_time').value,
                    room_id: parseInt(document.getElementById('room_id').value),
                    attendee_count: parseInt(document.getElementById('attendee_count')?.value || '1')
                };
                
                console.log('提交数据:', data);
                
                axios.post('/api/meetings/', data)
                    .then(res => {
                        alert('会议预约成功！');
                        window.location.href = '/my-meetings';
                    })
                    .catch(err => {
                        console.error('预约失败:', err);
                        alert('预约失败：' + (err.response?.data?.detail || '未知错误'));
                    });
            });
        }
    </script>
    {% block extrajs %}{% endblock %}
</body>
</html> 